package com.atlin.project.job.cycle;

import com.atlin.project.service.InterfaceInfoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @author atlin
 * @description 接口调用次数统计
 * @createDate 2024/11/23 23:25
 */
@Component
@Slf4j
public class InterfaceInfoInvokeCountTask {

    @Resource
    private InterfaceInfoService interfaceInfoService;


    /**
     * 每日 00:05:00秒执行
     */
    @Scheduled(cron = "0 5 0 * * ?")
    public void totalInvokeCountTask() {
        log.info("InterfaceInfoInvokeCountTask totalInvokeCountTask start");
        try {
            int count = interfaceInfoService.totalInvokeCount();
            log.info("---> 统计条目数：{}", count);
            log.info("InterfaceInfoInvokeCountTask totalInvokeCountTask success");
        } catch (Exception e) {
            log.error("InterfaceInfoInvokeCountTask totalInvokeCountTask failed", e);
        }
    }

}
